import { Component, OnInit } from '@angular/core';
import { JsonApiService } from "app/core/api/json-api.service"; //http请求配置引入
import { Router } from "@angular/router"; //路由引入

@Component({
  selector: 'sa-equipment-warning',
  templateUrl: './equipment-warning.component.html',
})
export class EquipmentWarningComponent implements OnInit {
	tableData:any[] = []; //table数据
	totalCount:number = 0; //分页总条数
	curPage:number = 1; //分页当前页
	pageSize:number = 10; //内置的分页每页条数
	searchKey:string = ''; //搜索keyword
	type:string = ''; // 设备类型
	typeList = [{ //设备list
		label: '传感器',
		value: '1'
	},{
		label: 'GSP定位',
		value: '2'
	},{
		label: '设备状态',
		value: '0'
	}];

	constructor(private jsonApiService: JsonApiService, private router: Router) {}

	ngOnInit() {
		this.load();
	}
	refresh(){
		this.load();
	}
	//	表格搜索
	table_search() {
		this.curPage = 1;
		this.searchKey = common.stringTrim(this.searchKey);
		this.load(); 
	}
	//  初始化加载list数据
	load() {
		let data = {
			pageSize:this.pageSize,
			nowPage:this.curPage,
			parameters:{
				searchKey:this.searchKey,
				type:this.type
			}
		}
		let reqdata = 'gridPager='+JSON.stringify(data);
		this.jsonApiService.http("log/logwarn.html", reqdata).subscribe(data => {
			this.tableData = data.exhibitDatas;
			this.totalCount = data.recordCount;
		})
	}
	//分页回调
	paginate(e){
		this.curPage = e.page+1;
		this.pageSize = e.rows;
		this.load();
	}
}
